package br.ufu.wcm.utils;

import java.security.MessageDigest;

public class SHA256 {
	
	public static String getHash(String string) {
		
		try {
			
			MessageDigest algorithm = MessageDigest.getInstance("SHA-256");
			byte messageDigest[] = algorithm.digest(string.getBytes("UTF-8"));
			 
			StringBuilder hexString = new StringBuilder();
			for (byte b : messageDigest) {
			  hexString.append(String.format("%02X", 0xFF & b));
			}
			
			return hexString.toString();
			
		} catch (Exception e) {
			
			return null;
			
			//TODO LOGAR
		}
	}

}
